@model WalletSetupViewModel
@{
    Layout = "_LayoutWalletSetup";
    ViewData.SetTitle(StringLocalizer["Enter your extended public key"]);
}

@section Navbar {
    <a asp-controller="UIStores" asp-action="ImportWallet" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" asp-route-method="">
        <vc:icon symbol="back" />
    </a>
}

<header class="text-center">
    <h1>@ViewData["Title"]</h1>
    <p class="lead text-secondary mt-3">
        <span text-translate="true">This key, also called "xpub", is used to generate individual destination addresses for your invoices.</span>
        <a href="https://docs.btcpayserver.org/FAQ/Wallet/#what-is-a-derivation-scheme" target="_blank" rel="noreferrer noopener" title="@StringLocalizer["More information..."]">
            <vc:icon symbol="info"/>
        </a>
    </p>
</header>

<form method="post" class="my-5">
    <input asp-for="Config" type="hidden" />
    <input asp-for="CryptoCode" type="hidden" />
    <input asp-for="AccountKey" type="hidden" />

    <div class="form-group">
        <label asp-for="DerivationScheme" class="form-label" text-translate="true">Extended public key</label>
        <textarea asp-for="DerivationScheme" class="form-control store-derivation-scheme font-monospace py-2" rows="2"></textarea>
        <span asp-validation-for="DerivationScheme" class="text-danger"></span>
    </div>

    <button name="command" type="submit" class="btn btn-primary" value="save" id="Continue" text-translate="true">Continue</button>
</form>
<style>
    #AddressTypes .additional { display: none; }
    #AddressTypes.expanded .additional { display: table-row; }
</style>
<table id="AddressTypes" class="table">
    <thead>
    <tr>
        <th class="w-175px" text-translate="true">Address type</th>
        <th text-translate="true">Example</th>
    </tr>
    </thead>
    <tbody>
    @if (Model.SupportSegwit)
    {
        <tr>
            <td rowspan="4">P2WPKH</td>
            <td class="font-monospace">xpub…</td>
        </tr>
        <tr>
            <td class="font-monospace">zpub…</td>
        </tr>
        <tr>
            <td class="font-monospace">wpkh(xpub…/0/*)</td>
        </tr>
        <tr>
            <td class="font-monospace">wpkh([…/84'/0'/0']xpub…/0/*)</td>
        </tr>
        <tr>
            <td rowspan="4">P2SH-P2WPKH</td>
            <td class="font-monospace">xpub…-[p2sh]</td>
        </tr>
        <tr>
            <td class="font-monospace">ypub…</td>
        </tr>
        <tr>
            <td class="font-monospace">sh(wpkh(xpub…/0/*)</td>
        </tr>
        <tr>
            <td class="font-monospace">sh(wpkh([…/49'/0'/0']xpub…/0/*)</td>
        </tr>
    }
    <tr>
        <td rowspan="3">P2PKH</td>
        <td class="font-monospace">xpub…-[legacy]</td>
    </tr>
    <tr>
        <td class="font-monospace">pkh([…/44'/0'/0']xpub…/0/*)</td>
    </tr>
    <tr>
        <td class="font-monospace">pkh(xpub…/0/*)</td>
    </tr>
    @if (Model.SupportTaproot)
    {
        <tr>
            <td rowspan="1">P2TR</td>
            <td class="font-monospace">xpub…-[taproot]</td>
        </tr>
    }
    </tbody>
    <tbody id="MultiSigExamples" class="collapse">
    <tr>
        <td class="text-nowrap" rowspan="2">Multi-sig P2WSH</td>
        <td class="font-monospace">2-of-xpub1…-xpub2…</td>
    </tr>
    <tr>
        <td class="font-monospace">wsh(multi(2,<br>[…/48'/0'/0'/2']xpub…/0/*,<br>[…/48'/0'/0'/2']xpub…/0/*))</td>
    </tr>
    <tr>
        <td class="text-nowrap" rowspan="2">Multi-sig P2SH-P2WSH</td>
        <td class="font-monospace">2-of-xpub1…-xpub2…-[p2sh]</td>
    </tr>
    <tr>
        <td class="font-monospace">sh(wsh(multi(2,<br>[…/48'/0'/0'/1']xpub…/0/*,<br>[…/48'/0'/0'/1']xpub…/0/*)))</td>
    </tr>
    <tr>
        <td class="text-nowrap" rowspan="2">Multi-sig P2SH</td>
        <td class="font-monospace">2-of-xpub1…-xpub2…-[legacy]</td>
    </tr>
    <tr>
        <td class="font-monospace">sh(multi(2,<br>[…/45'/0]xpub…/0/*,<br>[…/45'/0]xpub…/0/*))</td>
    </tr>
    </tbody>
</table>

<button class="d-inline-flex align-items-center btn btn-link text-primary fw-semibold p-0" type="button" id="ToggleAdditional" data-bs-toggle="collapse" data-bs-target="#MultiSigExamples" aria-expanded="false" aria-controls="MultiSigExamples">
    <vc:icon symbol="caret-down"/>
    <span class="ms-1" text-translate="true">Show multi-sig examples</span>
</button>
